﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Othello_Game
{
    /// <summary>
    /// The class describes a weight vector
    /// </summary>
    public class WeightVector
    {
        #region Public Properties
        /// <summary>
        /// Gets the WeightVector values in an array of double
        /// </summary>
        public double[] Weights { get; private set; }

        #endregion

        #region Ctor
        /// <summary>
        /// Initialize a Othello_Game.WeightVector Instanec
        /// </summary>
        /// <param name="weights">An array of double to initialize the weight vector with</param>
        public WeightVector(double[] weights)
        {
            this.Weights = weights;
        }

        #endregion

        #region Public Methods
        /// <summary>
        /// Returns the scalar dot product of the WeightVector with 
        /// the given array's values
        /// </summary>
        /// <param name="values">An array of doubles</param>
        /// <returns></returns>
        public double DotProduct(double[] values)
        {
            if (values.Count() != this.Weights.Count())
            {
                return double.NegativeInfinity;
            }
            double sum = 0.0;
            for (int i = 0; i < values.Count(); i++)
            {
                sum += values[i] * this.Weights[i];
            }
            return sum;
        }

        /// <summary>
        /// Returns the size of the weught vector
        /// </summary>
        /// <returns></returns>
        public int Count()
        {
            return this.Weights.Count();
        }

        /// <summary>
        /// Returns the value at the given place
        /// </summary>
        /// <param name="i">The index place at the vector</param>
        /// <returns></returns>
        public double at(int i)
        {
            return this.Weights[i];
        }
        #endregion
    }
}
